#include<iostream>
#include<vector>

using namespace std;

vector<string> removeAnagrams(vector<string>& words) {
    string base = "";
    int k = 0;
    for (auto& word : words)
    {
        string s = word;
        ranges::sort(s);
        if (s != base)
        {
            base = move(s);
            words[k++] = word;
        }
    }
    words.resize(k);
    return words;
}